<template>
	<view>
		<tt-bar title="客服中心" leftIcon="icon-back"></tt-bar>
		<view class="serverCnt">
			<view class="commonQuestion">
				<view class="commonTitle">常见问题</view>
				<view class="commonList">
					<view class="commonItme" @tap="toPage" :data-url="initInfo.help+'#dingdan'">
						<text class="iconfont icon-wenti"></text>
						<text class="itemText">订单问题</text>
					</view>
					<view class="commonItme" @tap="toPage" :data-url="initInfo.help+'#kaoqin'">
						<text class="iconfont icon-kaoqin"></text>
						<text class="itemText">考勤管理</text>
					</view>
					<view class="commonItme" @tap="toPage" :data-url="initInfo.help+'#zichan'">
						<text class="iconfont icon-caiwuguanli"></text>
						<text class="itemText">资产问题</text>
					</view>
					<view class="commonItme" @tap="toPage" :data-url="initInfo.help+'#qita'">
						<text class="iconfont icon-qita"></text>
						<text class="itemText">其他问题</text>
					</view>
				</view>
			</view>
			<view class="questionList">
				<view class="questionItem" @tap="toPage" :data-url="initInfo.help+'#qita'">
					<text class="qsText">入驻常见问题</text>
					<text class="iconfont icon-right"></text>
				</view>
				<view class="questionItem" @tap="toPage" :data-url="initInfo.help+'#qita'">
					<text class="qsText">如何创建店铺？</text>
					<text class="iconfont icon-right"></text>
				</view>
				<view class="questionItem" @tap="toPage" :data-url="initInfo.help+'#qita'">
					<text class="qsText">如何上架课程？</text>
					<text class="iconfont icon-right"></text>
				</view>
				<view class="questionItem" @tap="toPage" :data-url="initInfo.help+'#qita'">
					<text class="qsText">怎样提升商品的吸引力？</text>
					<text class="iconfont icon-right"></text>
				</view>
				<view class="questionItem" @tap="toPage" :data-url="initInfo.help+'#qita'">
					<text class="qsText">更多......</text>
					<text class="iconfont icon-right"></text>
				</view>
			</view>
		</view>
		
		<button class="serversBtn" @tap="toHuihua" v-if="isShow" >
			<text class="iconfont icon-kefu2"></text>
			<text class="btnText">在线客服</text>
		</button>
		
	</view>
</template>

<script>
	import ttBar from "@/components/ttBar/ttBar.vue";
	import COMM from "@/common/common.js"
	import API from "@/common/api.js";
	import {mapState} from "vuex";
	export default {
		components: {
			ttBar
		},
		computed:{
			...mapState({
				userInfo:state=>state.user.userInfo,
			})
		},
		data() {
			return {
				wbTop: uni.getSystemInfoSync().statusBarHeight + uni.upx2px(90),
				initInfo:{},
				isShow:true
			};
		},
		methods:{
			// 跳转到会话页面
			toHuihua(e){
				let toImid='user0'
				this.toPage({
					url: 'conversationDt',
					cvid: 'C2C' + toImid,
					toImId: toImid
				})
			},
			getXieyi(){
				API.getInitZation().then(res=>{
					if(res.data.result==1){
						this.initInfo=res.data.data
						uni.setStorageSync("initInfo",res.data.data)
					}else{
						this.initInfo=uni.getStorageSync("initInfo",res.data.data)
					}
				})
			}
		},
		onLoad() {
			this.getXieyi()
			if(this.userInfo.admin==1|| this.userInfo.roles.join(',').indexOf('3')>-1 ){
				this.isShow==true;
			}else{
				this.isShow=false;
			}
		},
		onPullDownRefresh() {
			setTimeout(() => {
				this.getXieyi()
				uni.stopPullDownRefresh();
			}, 1500)
		}
	}
</script>

<style lang="less">
	page {
		background-color: #f6f6f6;
	}

	.serverCnt {
		padding: 0 18upx;
		padding-top: 14upx;

		.commonQuestion {
			background-color: #FFFFFF;
			box-shadow: 0rpx 3rpx 17rpx 0rpx rgba(201, 202, 208, 0.15);
			display: flex;
			flex-direction: column;
			border-radius: 16upx;

			.commonTitle {
				padding: 24upx 67upx;
				font-size: 32rpx;
				font-weight: bold;
				color: #202932;
			}

			.commonList {
				display: flex;
				flex-wrap: wrap;
				padding: 0 85upx;
				justify-content: space-between;

				.commonItme {
					display: flex;
					width: 40%;
					align-items: center;
					margin-bottom: 35upx;

					.iconfont {
						font-size: 48upx;
						color: #ffb423;
						margin-right: 15upx;
					}

					.itemText {
						font-size: 28rpx;
						color: #202932;
					}

				}
			}
		}

		.questionList {
			background-color: #FFFFFF;
			box-shadow: 0rpx 3rpx 17rpx 0rpx rgba(201, 202, 208, 0.15);
			display: flex;
			flex-direction: column;
			border-radius: 16upx;
			margin-top: 14upx;
			padding: 0 24upx;

			.questionItem {
				border-bottom: 1px solid #e7e7e7;
				height: 89upx;
				line-height: 89upx;
				padding-bottom: 23upx;
				padding-left: 30upx;
				padding-right: 20upx;
				display: flex;
				justify-content: space-between;

				.qsText {
					font-size: 28rpx;
					color: #9691b2;
				}
				.iconfont{
					font-size: 28upx;
					color: #c6c6c6;
				}
			}
		}
	}
</style>
